<include file="Public/popHeader" />
<body class="hold-transition skin-blue sidebar-mini">
<style type="text/css">
ul li{
	list-style: none;
	padding: 0;
	margin: 0;
}
.list-table{
    display: table-cell;
}
.list-group{
    padding-left: 20px;
    width: 91%;
}
.list-tameple{
    margin-left: 10px;
    position: relative;
    top:10px;
}

</style>
<div class="row">
    <div class="col-md-12">
        <div class="box">
            <form action="/admin/rbac/roleAddMenu/id/1" method="post">
                <!-- /.box-header -->
                <div class="box-body  no-padding">
                    <ul class="list-table">
                        <volist name="list" id="item">
                            <li data-id={$item.id} >
                                <input type="checkbox"/>
                                {$item.text}
                                <ul  class="list-group">
                                    <volist name="item['nodes']" id="item1">
                                        <li data-id={$item1.id} class="list-tameple">
                                            <input type="checkbox"/>
                                            {$item1.text}
                                                <ul class="list-group list-position">
                                                    <volist name="item1['nodes']" id="item2">
                                                        <li data-id={$item2.id} style="display:inline" class="list-tameple">
                                                            <input type="checkbox"/>
                                                            {$item2.text}
                                                        </li>
                                                    </volist>
                                                </ul>
                                        </li>
                                    </volist>
                                </ul>
                            </li>
                        </volist>
                    </ul>
                </div>
                <div class="box-footer clearfix">

                    <button type="button" class="btn btn-sm btn-success" id="btn-check-all">全选</button>
                    <button type="button" class="btn btn-sm btn-danger" id="btn-uncheck-all">全不选</button>

                    <!--<input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;-->

                    <input type="submit" class="btn btn-sm btn-primary grid-refresh">

                </div>
            </form>
        </div>
    </div>
</div>

</body>
<!-- 底部 -->
<script src="/Public/admin/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/Public/admin/adminlte/bootstrap/js/bootstrap.min.js"></script>


<!-- AdminLTE App -->
<script src="/Public/admin/adminlte/dist/js/app.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/Public/admin/adminlte/dist/js/demo.js"></script>
<script src="/Public/admin/adminlte/plugins/iCheck/icheck.min.js"></script>

<script type="text/javascript">


</script>
<script data-exec-on-popstate>

    $(function () {

        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        /*$('.open1').on('click', function () {
            var id = $(this).prev('span').attr('data-id');
            var _this = $(this);
            var html = '';
            /!**
             <tr>
             <td><input type="checkbox" class="grid-item" data-id="{$vo.region_id}"></td>
             <td><span class="name-editable editable-click-1" data-id="{$vo.region_id}" data-type="text" data-pk="1">{$vo.local_name}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
             href="javascript:;" class="label label-success open1">+</a></td>
             <td><span class="name-editable editable-click-2" data-id="{$vo.region_id}" data-type="text" data-pk="2"></span></td>
             <td><span class="name-editable editable-click-3" data-id="{$vo.region_id}" data-type="text" data-pk="3"></span></td>
             </tr>
             *!/

            /!*html += '<tr>';
            html += '<td><input type="checkbox" class="grid-item" data-id="'+region_id+'"></td>';
            html += '<td><span class="name-editable editable-click-1" data-id="" data-type="text" data-pk="1"></span></td>';
            html += '<td><span class="name-editable editable-click-2" data-id="'+region_id+'" data-type="text" data-pk="2">'+local_name+'</span>';
            html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" class="label label-success open1">+</a></td>';
            html += '<td></td>';
            html += '<tr>';*!/
            //console.log(html);


            var next_data_id = _this.parents('tr').next('tr').find('.grid-item').hasClass('second');
            if (!id || next_data_id == true) {
                $('tr').each(function () {

                });

                return false;
            }
            $.ajax({
                type: "get",
                url: "{:U('Freight/getChildsAddress','')}",
                data: {id: id},
                success: function (msg) {
                    //console.log(msg.data['length']);
                    if (msg.data['length'] > 0) {
                        for($i = 0; $i < msg.data['length']; $i++) {
                            html += '<tr>';
                            html += '<td></td>';
                            html += '<td><span class="name-editable editable-click-1" data-id="" data-type="text" data-pk="1"></span></td>';
                            html += '<td><input type="checkbox" class="grid-item second" data-id="'+msg.data[$i]['region_id']+'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="name-editable editable-click-2" data-id="'+msg.data[$i]['region_id']+'" data-type="text" data-pk="2">'+msg.data[$i]['local_name']+'</span>';
                            html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" class="label label-success open2">+</a></td>';
                            html += '<td></td>';
                            html += '<tr>';
                        }
                    }
                    _this.parents('tr').after(html);
                    //console.info(msg.data);
                    //window.location.reload();
                },
                error: function (msg) {
                    alert(msg.message);
                }
            });
        });*/

        $('.table-hover').on('click', 'tr', function (i) {
            var _this = $(this);
            var second = _this.find('td').eq(2);
            if (second.text() != ''){
                console.log($(this));
            }
        });

        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引

        $('.batch-choose').on('click', function (e) {

            var data = [];
            var exists = parent.$('.ui-sortable').find('li input');
            var exists_ids = [];
            exists.each(function () {
                exists_ids.push($(this).val());
            });

            var qyname = $('#qyname').val();
            var firstunit = $('#firstunit').val();
            var firstprice = $('#firstprice').val();
            var continueunit = $('#continueunit').val();
            var continueprice = $('#continueprice').val();
            var values = qyname + '-' + firstunit + '-' + firstprice + '-' + continueunit + '-' + continueprice;

            var html = '';
            html += '<li class="">';
            html += '<input type="hidden" name="value[]" value="' + values + '">';
            html += '<span class="handle ui-sortable-handle">';
            html += '<i class="fa fa-ellipsis-v"></i>\n\r';
            html += '<i class="fa fa-ellipsis-v"></i>';
            html += '</span>\n\r';
            html += '<small class="label label-warning"> 区域名称 : ' + qyname + '</small>\n\r';
            html += '<small class="label label-warning"> 首重 : ' + firstunit + 'Kg</small>\n\r';
            html += '<small class="label label-success"> 首重运费 : ' + firstprice + '元</small>';
            html += '<small class="label label-success"> 续重 : ' + continueunit + 'Kg</small>';
            html += '<small class="label label-success"> 续重费 : ' + continueprice + '元</small>';
            html += '<div class="label"><a href="#" class="add_area">添加地区</a></div>';
            html += '<div class="tools">';
            html += '<i class="fa fa-trash-o icondel"></i>';
            html += '</div>';
            html += '</li>';

            parent.$('.ui-sortable').append(html);
            parent.$('.col-sm-offset-2').removeClass('hide');

            parent.layer.close(index);
        })

    });
</script>
</html>

